/*
 * Copyright (C) 2010-2011 Graz University of Technology, Austria. All Rights reserved. 
 *
 * Contact: Simone Kopeinik <simone.kopeinik@tugraz.at>
 * 	   Graz University of Technology, Knowledge Management Institute, Brückenkopfgasse 1/6, 8020 Graz 	
 * 	   <http://www.kmi.tugraz.at/>
 * 
 * This software is part of the TARGET platform developed by the
 * TARGET EC-funded project www.reachyourtarget.org
 *
 * This software is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, version 3.
 *
 * This software is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 *
 * The GNU General Public License is available at <http://www.gnu.org/licenses/>.
 *
 */
package at.tugraz.kmi.css.cbkst2;

import java.io.Serializable;
import java.util.concurrent.atomic.AtomicInteger;

import at.tugraz.kmi.css.commons.Bean;

/**
 * The Immutable Version of any Vertex
 * 
 * @author Georg Öttl
 *
 */
public abstract class ImmutableCbKSTVertex extends Bean implements
		Serializable, Comparable<ImmutableCbKSTVertex> {

	/** A unique ID for this vertex. */
	protected String				id;
	/** A human Readable Name for this CbKSTCompetence */
	protected String				name;
	protected String				description;
	/**
	 * Used to automatically increment the counter value for the empty
	 * constructor in a threadsafe way.
	 */
	private static AtomicInteger	counter	= new AtomicInteger(0);

	/**
	 * Thread safe increasing of the counter.
	 * 
	 * @return an incremented counter value.
	 */
	protected static final int incrementCounter() {
		return counter.addAndGet(1);
	}

	public ImmutableCbKSTVertex() {
		super();
	}

	/**
	 * @return the ID of this vertex
	 */
	public String getId() {
		return id;
	}

	/**
	 * 
	 * @return the name of the vertex
	 * 
	 */
	public String getName() {
		return name;
	}

	/**
	 * Returns the description of this vertex.
	 * 
	 * @return The description of this vertex.
	 */
	public String getDescription() {
		return description;
	}

	/**
	 * @see java.lang.Object#hashCode()
	 */
	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((id == null) ? 0 : id.hashCode());
		return result;
	}

	@Override
	public int compareTo(ImmutableCbKSTVertex o) {
		return o.getId().compareTo(id);
	}

	/**
	 * @see java.lang.Object#equals(java.lang.Object)
	 */
	@Override
	public boolean equals(Object obj) {
		if (this == obj) {
			return true;
		}
		if (obj == null) {
			return false;
		}
		if (getClass() != obj.getClass()) {
			return false;
		}
		CbKSTVertex other = (CbKSTVertex) obj;
		if (id == null) {
			if (other.id != null) {
				return false;
			}
		} else if (!id.equals(other.id)) {
			return false;
		}
		return true;
	}

}